package com.chanzany.singleton.type7;


public class SingletonTest {
    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 1000; i++) {
            new Thread(()->{
                Singleton instance = Singleton.getInstance();
            }).start();
        }
    }
}

/**
 * 懒汉式（静态内部类）
 */
class Singleton{
    private Singleton(){}
    private static  class SingletonInstance{
      private static final Singleton INSTANCE = new Singleton();
    }
    public  static Singleton getInstance(){
        return SingletonInstance.INSTANCE;
    }
}
